//
//  HTRootController.m
//  HappyTravel
//
//  Created by Apple on 2018/8/2.
//  Copyright © 2018年 Apple. All rights reserved.
//

#import "HTRootController.h"
#import "HTTabBarController.h"
#import "HTBaseNavController.h"
#import "HTHomeViewController.h"
#import "HTMoodViewController.h"
#import "HTStatisticsViewController.h"

@interface HTRootController ()

@property (nonatomic, strong) HTTabBarController *tabBar;
@property (nonatomic, strong) HTBaseNavController *navController;

@property (nonatomic, strong) HTHomeViewController *vc1;
@property (nonatomic, strong) HTMoodViewController *vc2;
@property (nonatomic, strong) HTStatisticsViewController *vc3;

@end

@implementation HTRootController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tabBar = [[HTTabBarController alloc] init];
    [self addChildViewController:self.tabBar];
    [self.view addSubview:self.tabBar.view];
    
    [self setupTabBar];
}

#pragma mark - CustomMethod
- (void)setupTabBar {
    
    [_tabBar resetTabBarView];
    if (_vc1 == nil) {
        _vc1 = [[HTHomeViewController alloc] init];
    }
    HTBaseNavController *homeNav = [[HTBaseNavController alloc] initWithRootViewController:_vc1];
    
    if (_vc2 == nil) {
        _vc2 = [[HTMoodViewController alloc] init];
    }
    HTBaseNavController *moodNav = [[HTBaseNavController alloc] initWithRootViewController:_vc2];
    
    if (_vc3 == nil) {
        _vc3 = [[HTStatisticsViewController alloc] init];
    }
    HTBaseNavController *staticsNav = [[HTBaseNavController alloc] initWithRootViewController:_vc3];
    
    _tabBar.viewControllers = @[homeNav,moodNav,staticsNav];
    _tabBar.selectedIndex = 0;
}






@end
